# -*- coding: utf-8 -*-

import scrapy

class IndexSpider(scrapy.Spider):
    name = "vxinghe_detail"
    start_urls = [
        'http://vxinghe.com/news/d15155621356303.html',
    ]
    # def start_requests(self):
    #     return [scrapy.FormRequest("http://www.vxinghe.com/",
    #                                formdata={'user': 'john', 'pass': 'secret'},
    #                                callback=self.logged_in)]
    # def logged_in(self, response):
    #     print("哈哈哈哈哈哈")

    def parse(self, response):
        basePath = '//div[@class="article"]'
        titlePath = './/div[@class="article-title"]/text()'
        descPath = './/div[@class="article-content"]'
        fromPath = './/span[@class="article-from"]/a/text()'
        for quote in response.xpath(basePath):
            item = {
                'title': quote.xpath(titlePath).extract_first(),
                'desc': quote.xpath(descPath).extract_first(),
                'from1': quote.xpath(fromPath).extract_first()
            }
        yield item
        # next_page_url = response.xpath('//li[@class="next"]/a/@href').extract_first()
        # if next_page_url is not None:
        #     yield scrapy.Request(response.urljoin(next_page_url))


